package com.acme.domain.account;

import java.util.Comparator;

public class AccountByBalanceComparator implements Comparator<Account> {
    private final boolean ascending;

    public AccountByBalanceComparator(boolean ascending) {
        this.ascending = ascending;
    }

    @Override
    public int compare(Account a, Account b) {
        return (ascending ? 1 : -1) * a.getBalance().compareTo(b.getBalance());
    }
}